<style>
.artNo .artNo_top .el-input__inner {
  width: 8vw;
  height: 30px;
}
.artNo .artNo_top .el-input {
  width: 8vw;
  height: 30px;
}
.artNo .el-icon-success,
.artNo .el-icon-delete {
  margin-right: 7px;
}
.artNo .el-button {
  padding: 8px 9px;
  margin-right: 12px;
  height: 30px;
}
.artNo .el-button + .el-button {
  margin-left: 0;
}
.artNo .artNo_button span .el-input__inner {
  width: 8vw;
  height: 30px;
}
.artNo .el-input__icon {
  line-height: 30px;
}
.artNo .el-input-group__append {
  background-color: #ecf5ff;
  color: #409eff;
}
</style>

<style scoped lang="less">
.artNo {
  margin-right: 0.5vw;
  padding-left: 15px;
  background-color: white;
  height: 95vh;
  position: relative;
  padding: 0 15px;
}
.artNo_w {
  padding: 2px 6px 0 0;
  margin-top: 15px;
}
/deep/.el-select {
  .el-select__tags {
    top: 34%;
  }
}
.l {
  margin-left: 16px;
}
.artNo_button {
  margin: 15px 0 15px 0;
  white-space: nowrap;
  display: flex;
}
.artNo_button span {
  display: inline-block;
  position: relative;
  left: 625px;
  width: 235px;
}
.artNo_button span p {
  display: inline-block;
  line-height: 30px;
}
.artNo_top {
  height: 60px;
  display: flex;
  white-space: nowrap;
  padding-top: 15px;
  border-bottom: 2px solid #f4f4f4;
}
.artNo_w {
  padding: 2px 6px 0 0;
  margin-top: 0;
}
.artNo_button1 {
  margin: 0 0 0 -2px;
  width: 36px;
  height: 30px;
  font-size: 14px;
  /* border:1px solid #dbdbdb;
	*/
  padding: 0 0 0 0;
  background: #dbdbdb;
  white-space: nowrap;
}
.artNo_button2 {
  height: 30px;
  margin: 0 0 0 16px;
  line-height: 6px;
}
.mask {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: #000;
  opacity: 0.3;
  z-index: 9;
}
.tz {
  text-decoration: none;
  color: black;
}
.tz:hover {
  color: #017aff;
}
.footView span {
  float: left;
  margin-right: 48px;
  line-height: 6vh;
  font-size: 14px;
}
.footView span i {
  margin-right: 5px;
}
</style>

<template>
  <!-- 货号建档 -->
  <div class="artNo">
    <!-- 新建 -->
    <div class="mask" :style="{ display: show }"></div>
    <newly-build
      class="newBuild"
      :style="{ display: show }"
      @closeClick="closeClick"
      @addArtNoSuc="addArtNoSuc"
      @edit="edit"
      :detailInfo="details"
      :isCreate="isCreate"
      :show="show"
      :waveBandList="waveBandList"
    ></newly-build>
    <div class="artNo_top">
      <p class="artNo_w">助记码</p>
      <el-input v-model="mnemonicCode" clearable></el-input>
      <p class="artNo_w l">大类</p>
      <el-select v-model="commodityType" clearable>
        <el-option
          v-for="item in commodityTypeList"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        ></el-option>
      </el-select>
      <p class="artNo_w l">货号</p>
      <el-input
        v-model="kindsNumber"
        key="artNo1"
        @keyup.enter.native="searchArtNo"
      >
        <el-button @click="addNumber" slot="append" style="width: 30px"
          >添加</el-button
        ></el-input
      >
      <p class="artNo_w l">品牌</p>
      <el-select v-model="brandedName" clearable>
        <el-option
          v-for="item in brandedNameList"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        ></el-option>
      </el-select>
      <p class="artNo_w l">季度</p>
      <el-select
        class="select_wrap"
        v-model="quarterArray"
        multiple
        collapse-tags
        clearable
        @change="changeQuarterName"
      >
        <el-option
          v-for="(item, _index) in quarterList"
          :key="_index"
          :label="item.name"
          :value="item.id"
        >
        </el-option>
      </el-select>
      <el-button
        icon="el-icon-search"
        style="margin-left: 15px"
        @click="searchArtNo"
        >查询</el-button
      >
      <p class="artNo_w l">款号/色号</p>
      <el-input v-model="newKindsNumber" clearable></el-input>
      <el-tooltip
        class="item"
        effect="dark"
        content="修改此货号的 款号/色号信息"
        placement="top-start"
      >
        <el-button @click="Revision" class="artNo_button2" type="primary"
          >改订/删号</el-button
        ></el-tooltip
      >
    </div>
    <!-- 按钮 -->
    <div class="artNo_button">
      <el-button @click="newClick" type="primary" icon="el-icon-plus"
        >新建</el-button
      >
      <el-dropdown>
        <el-button type="primary" icon="el-icon-printer"
          >打印条码 <i class="el-icon-arrow-down"></i
        ></el-button>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item
            @click.native="Send"
            v-for="item in tags1"
            :key="item.title"
          >
            <router-link
              :to="{
                path: '/basic_info/tags1',
                query: { fid: item.id, name: 'tags1', label: item.title }
              }"
              class="tz"
              >{{ item.title }}</router-link
            ></el-dropdown-item
          >
          <el-dropdown-item
            @click.native="Send"
            v-for="item in tags2"
            :key="item.title"
          >
            <router-link
              :to="{
                path: '/basic_info/tags2',
                query: { fid: item.id, name: 'tags2', label: item.title }
              }"
              class="tz"
              >{{ item.title }}</router-link
            ></el-dropdown-item
          >
        </el-dropdown-menu>
      </el-dropdown>
      <el-button icon="el-icon-edit-outline" @click="editClick(details)"
        >编辑</el-button
      >
      <el-button icon="el-icon-edit-outline" @click="correctCT"
        >改正部类</el-button
      >
      <el-tooltip
        placement="top"
        effect="light"
        content="注意：表头有空格可能导致新建失败"
      >
        <!-- <div class="dr">
          <i class="el-icon-download"></i>导入表格
          <input
            @change="readExcel"
            accept=".xls, .xlsx"
            class="outputlist_upload"
            type="file"
            ref="upload"
          />
        </div> -->
        <el-button size="small" class="a-upload el-icon-download"
          >导入表格
          <template>
            <input
              type="file"
              accept=".xlsx,.xls"
              @change="handleImportInputClick"
              class="file"
              id="file"
            />
          </template>
        </el-button>
      </el-tooltip>
      <el-button size="small" class="a-upload el-icon-download"
        >批量导入修改
        <template>
          <input
            type="file"
            accept=".xlsx,.xls"
            @change="handleImportInputUpdateClick"
            class="file"
            id="file"
          />
        </template>
      </el-button>
      <el-dropdown @command="handleCommand">
        <el-button icon="el-icon-upload2"
          >导出货号 <i class="el-icon-arrow-down"></i
        ></el-button>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="0">货号</el-dropdown-item>
          <el-dropdown-item command="1">款号色号</el-dropdown-item>
          <el-dropdown-item command="2">款号</el-dropdown-item>
          <el-dropdown-item command="3">代销商</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
      <el-button @click="dele" icon="el-icon-delete">删除</el-button>
      <span>
        <p>表格类型</p>
        <el-select
          v-model="tableType"
          style="float: right; height: 100%"
          @change="typeChange"
        >
          <el-option
            v-for="item in tableTypeList"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </span>
    </div>
    <!-- 表格 -->
    <el-table
      ref="table"
      :data="tableData"
      height="75vh"
      :header-cell-style="{ background: '#f4f4f4', padding: 0, height: '40px' }"
      :cell-style="{ padding: 0, height: '40px' }"
      tooltip-effect="dark"
      highlight-current-row
      @row-dblclick="editClick"
      @row-click="rowClick"
    >
      <el-table-column
        prop="styleNumber"
        label="款号"
        width="100"
        v-if="tableHeader.indexOf('款号') != -1"
      ></el-table-column>
      <el-table-column
        prop="kindsNumber"
        label="货号"
        width="140"
        v-if="tableHeader.indexOf('货号') != -1"
      ></el-table-column>
      <el-table-column
        prop="supplier"
        label="供应商"
        width="70"
        v-if="tableHeader.indexOf('供应商') != -1"
      ></el-table-column>
      <el-table-column
        prop="mnemonicCode"
        label="助记码"
        width="70"
        v-if="tableHeader.indexOf('助记码') != -1"
      ></el-table-column>
      <el-table-column
        prop="colorNo"
        label="色号"
        width="60"
        v-if="tableHeader.indexOf('色号') != -1"
      ></el-table-column>
      <el-table-column
        prop="colorName"
        label="颜色"
        width="80"
        v-if="tableHeader.indexOf('颜色') != -1"
      ></el-table-column>
      <el-table-column
        prop="manufacturerPrice"
        label="厂价"
        width="80"
        v-if="tableHeader.indexOf('厂价') != -1"
      ></el-table-column>
      <el-table-column
        prop="sellingPrice"
        label="售价"
        width="80"
        v-if="tableHeader.indexOf('售价') != -1"
      ></el-table-column>
      <el-table-column
        prop="sellingPriceOne"
        label="正价"
        width="80"
        v-if="tableHeader.indexOf('正价') != -1"
      ></el-table-column>
      <el-table-column
        prop="sellingPriceTwo"
        label="售价2"
        width="80"
        v-if="tableHeader.indexOf('售价2') != -1"
      ></el-table-column>
      <el-table-column
        prop="sellingPriceThree"
        label="售价3"
        width="80"
        v-if="tableHeader.indexOf('售价3') != -1"
      ></el-table-column>
      <el-table-column
        prop="sellingPriceFour"
        label="售价4"
        width="80"
        v-if="tableHeader.indexOf('售价4') != -1"
      ></el-table-column>
      <el-table-column
        prop="vipPrice"
        label="VIP价"
        width="80"
        v-if="tableHeader.indexOf('VIP价') != -1"
      ></el-table-column>
      <el-table-column
        prop="typeName"
        label="部类名称"
        width="100"
        v-if="tableHeader.indexOf('部类名称') != -1"
      ></el-table-column>
      <el-table-column
        prop="commodityName"
        label="品名"
        min-width="100"
        v-if="tableHeader.indexOf('品名') != -1"
      ></el-table-column>
      <el-table-column
        prop="brandedName"
        label="品牌"
        min-width="100"
        v-if="tableHeader.indexOf('品牌') != -1"
      ></el-table-column>
      <el-table-column
        prop="quarterName"
        label="季度"
        width="100"
        v-if="tableHeader.indexOf('季度') != -1"
      ></el-table-column>
      <el-table-column
        prop="size"
        label="尺码"
        width="50"
        v-if="tableHeader.indexOf('尺码') != -1"
      ></el-table-column>
      <el-table-column
        prop="kindsNumber"
        label="条码"
        width="160"
        v-if="tableHeader.indexOf('条码') != -1"
      ></el-table-column>
      <el-table-column
        prop="waveBand"
        label="波段"
        width="60"
        v-if="tableHeader.indexOf('波段') != -1"
      ></el-table-column>
      <el-table-column
        prop="matchStyle"
        label="搭配款"
        width="80"
        v-if="tableHeader.indexOf('搭配款') != -1"
      ></el-table-column>
      <el-table-column
        prop="originalManufacturerKindsNumber"
        label="原厂商货号"
        width="160"
        v-if="tableHeader.indexOf('原厂商货号') != -1"
      ></el-table-column>
      <el-table-column
        label="图像"
        width="80"
        v-if="tableHeader.indexOf('图像') != -1"
        key="图像"
      >
        <template slot-scope="scope">
          <p style="color: #017aff" @click="check(scope.row)">查看大图</p>
        </template>
      </el-table-column>
      <el-table-column
        prop="accessoryName"
        label="附件"
        width="80"
        v-if="tableHeader.indexOf('附件') != -1"
      ></el-table-column>
      <el-table-column
        prop="commodityType"
        label="部类"
        width="50"
        v-if="tableHeader.indexOf('部类') != -1"
      ></el-table-column>
      <el-table-column
        prop="differentiateCondition"
        label="区分条件"
        width="140"
        v-if="tableHeader.indexOf('区分条件') != -1"
      ></el-table-column>
    </el-table>
    <foot-view
      class="footView"
      :pagesNum="pagesNum"
      :hasPagination="true"
      :pageSize="limit"
      :tableTypeChange="tableTypeChange"
      @handleSizeChange="handleSizeChange"
      @handleCurrentChange="handleCurrentChange"
    >
      <div slot="text">
        <span>数据库：{{ jxQuarter }}</span>
      </div>
    </foot-view>

    <show-image
      v-if="showImg"
      :imgSrc="imgSrc"
      @closeImg="
        () => {
          this.showImg = false
        }
      "
    ></show-image>
  </div>
</template>

<script>
import {
  getArtNo,
  getExportLink,
  correctCommodityType,
  getCategory,
  putkindsNumber,
  deleteArtNo,
  postKindsNumber,
  getKindsNumberIngredient,
  postKindsNumberIngredient,
  putKindsNumberIngredient,
  importKindsNumber,
  importKindsNumberByUpdate
} from '../../../network/artNo'
import { getBranded } from '../../../network/branded'
import { getManufacturer } from '../../../network/manufacturer'
import { getSize } from '../../../network/size'
import { getQuarter, postQuarter } from '../../../network/quarter'
import { getCommodityType, getCommodityName } from '../../../network/commodity'

import newlyBuild from './childTem/newlyBuild'
import footView from '../../../components/FootView'
import exportMethods from '../../../components/mixins/exportMethods'
import showImage from '../../../components/showImage.vue'

import table2excel from 'js-table2excel'
import XLSX from 'xlsx'
import FileSaver from 'file-saver'
import enterUp from '../../../components/mixins/enterUp'
import { getWashdata } from '../../../network/tags'
import { exportExcel, importExcel } from '@/util/dealWithExcel'

import {
  exportExcel_2,
  isBoolean_isExport_excel
} from '../../../util/exportExcel.js'

export default {
  name: 'art_no',
  mixins: [enterUp, exportMethods],
  created() {
    let jxQuarterVal = document.cookie.match(RegExp('jxQuarter' + '=([^;]+)'))
    this.jxQuarter = jxQuarterVal ? jxQuarterVal[1] : null

    localStorage.jxPrintList = ''
    this.inpList = this.getInput()
    this.getAllData()
    //查询部类
    getCategory({ limit: 99999 }).then((res) => {
      // console.log(res)
      let list = res.data.data
      this.commodityTypeList = []
      list.forEach((element) => {
        this.commodityTypeList.push({ label: element.type, value: element.no })
      })
    })
    // 品牌公司列表赋值
    getBranded({ limit: 99999 }).then((res) => {
      let list = res.data.data
      this.brandedNameList = []
      list.forEach((e) => {
        this.brandedNameList.push({
          value: e.name,
          label: e.name,
          company: e.brandedCompany
        })
      })
    })
    // 查部类
    getCommodityType({ limit: 999, page: 1 }).then((res) => {
      // console.log(res)
      this.commodityList = res.data.data || []
    })
    // 获取季度
    getQuarter({ limit: 99999 }).then((res) => {
      // console.log(res.data.data)
      if (res.data.data) {
        let obj = {}
        this.quarterList = res.data.data
        res.data.data.forEach((e) => {
          obj[e.name] = e.id
        })
        this.quarterMap = obj
      }
    })

    getSize({ limit: 9999 }).then((res) => {
      let map = {}
      res.data.data.forEach((e) => {
        if (!map[e.kind]) {
          map[e.kind] = {}
        }
        map[e.kind][e.size] = e
      })
      this.sizeMap = map
    })
  },
  components: {
    newlyBuild,
    footView,
    showImage
  },
  data() {
    return {
      showImg: false,
      imgSrc: '',
      inpList: [],
      content: [],
      waveBandList: [],
      allData: [],
      // 总数据条数
      dataLen: 0,
      // 总页码
      pagesNum: 0,
      // 分页条数
      limit: 20,
      // 当前页码
      currentPage: 1,
      tableTypeChange: false,

      tableData: [],
      allData: [],
      styleNumberList: [],
      styleNumberColorList: [],
      tableHeader: [
        '款号',
        '厂价',
        '部类名称',
        '色号',
        '颜色',
        '供应商',
        '助记码',
        '季度',
        '售价',
        '正价',
        '售价2',
        '售价3',
        '售价4',
        'VIP价',
        '品名',
        '品牌',
        '部类'
      ],
      id: '',
      options: [],
      kindsNumber: '',
      mnemonicCode: '',
      newKindsNumber: '',
      commodityType: '',
      commodityTypeList: [],
      brandedName: '',
      brandedNameList: [],
      commodityList: [],
      show: 'none', // none 不显示 block 显示
      tags1: [
        { title: '列印吊牌1', id: 0, name: '/basic_info/tags1' },
        { title: '列印洗标1', id: 1, name: '/basic_info/tags1' }
      ],
      tags2: [
        { title: '列印吊牌2', id: 0, name: '/basic_info/tags2' },
        { title: '列印洗标2', id: 1, name: '/basic_info/tags2' }
      ],
      tableType: 3,
      tableTypeList: [
        {
          label: '货号',
          value: 1
        },
        {
          label: '款号色号',
          value: 3
        },
        {
          label: '款号',
          value: 2
        }
      ],
      details: {},
      isCreate: '',
      jxQuarter: null,
      // jxQuarter: document.cookie.match(RegExp('jxQuarter' + '=([^;]+)'))[1],
      quarterMap: {},
      sizeMap: {},
      clickStyle: '',
      // 新增
      quarterList: [],
      quarterArray: [],
      quarterName: '',
      quarter: null
    }
  },
  methods: {
    /**
     * ---------- 新增 ---------------
     */
    // 选择季度
    changeQuarterName(id) {
      // let item = this.quarterList[_index]
      // this.quarter = item.id
      // this.quarterName = item.name
      // console.log(this.quarter, this.quarterName)
    },
    /**
     * ---------- 结束 ---------------
     */
    Send() {
      localStorage.jxPrintList = this.content
      var io = JSON.stringify(this.content).replace(/^\{|\}$/g, '')
      // console.log(io)
      var ip = io.replace(/\[|]/g, '').replace(/\"|"/g, '')
      // console.log(ip)
      if (ip == '') {
        return
      }
      let obj = { kindsNumberList: ip }
      // console.log(obj)
      getWashdata(obj).then((res) => {
        // console.log(res.data)
        var sdMsg = res.data.data
        // var sdMsg2 = sdMsg       //将数组里kindsNumber对象里的属性拿出来放置与kindsNumber平级
        if (sdMsg != null) {
          sdMsg.map((item, index) => {
            sdMsg.push(
              Object.assign({}, item, {
                kindsNumbers: item.kindsNumber.kindsNumber,
                colorName: item.kindsNumber.colorName,
                colorNo: item.kindsNumber.colorNo,
                sellingPrice: item.kindsNumber.sellingPrice,
                sizeNo: item.kindsNumber.sizeNo,
                mnemonicCode: item.kindsNumber.mnemonicCode,
                finishNumber:
                  item.barcodeWashPrint == null
                    ? 0
                    : item.barcodeWashPrint.finishNumber
              })
            )
          })
        }
        // console.log(sdMsg) //map复制了数组 添加的数组里深层对象为空去掉为空
        var sdMsg2 = []
        for (let ab of sdMsg) {
          if (ab.sizeNo != undefined || ab.colorNo != undefined) {
            sdMsg2.push(ab)
          }
        }
        // console.log(sdMsg2);

        this.$root.Bus.$emit('send', sdMsg2)
      })
    },

    // 查询
    searchArtNo() {
      let params = {
        kindsNumberStr: this.kindsNumber,
        mnemonicCode: this.mnemonicCode,
        commodityType: this.commodityType,
        brandedName: this.brandedName,
        quarterIdList: String(this.quarterArray)
      }
      // console.log(params)
      this.getAllData(params)
    },
    // 删除
    dele() {
      if (this.id == '') {
        this.$message({
          type: 'error',
          message: '请选择要删除的数据!'
        })
        return
      }
      this.$confirm('确认删除？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          let params = {}
          switch (this.tableType) {
            case 1:
              params = { id: this.id }
              break
            case 3:
              params = {
                styleNumber: this.details.styleNumber,
                colorNo: this.details.colorNo
              }
              break
            case 2:
              params = {
                styleNumber: this.details.styleNumber
              }
              break
          }

          deleteArtNo(params).then((res) => {
            // console.log(res)
            if (res.data.code == 200) {
              this.$message({
                message: '删除成功',
                type: 'success'
              })
              this.kindsNumber = ''
              this.dataLen--
              this.getAllData({
                kindsNumberStr: this.kindsNumber,
                mnemonicCode: this.mnemonicCode,
                commodityType: this.commodityType,
                brandedName: this.brandedName
              })
            }
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },

    // 改订/删号  第一步修改客户订单第二部删除货号数据
    Revision() {
      if (this.tableType != 1) {
        this.$message.info('改订/删号只对货号使用')
        return
      }
      if (this.kindsNumber == '' || this.newKindsNumber == '') {
        this.$message({
          type: 'info',
          message: '货号或款号/色号不能为空'
        })
        return
      }
      // 以货号MCC-A0001-01和款号/色号MCC-A0001-02为例

      // 第一步：删除或修改客户订单
      // 如果客户订单有MCC-A0001-01也有MCC-A0001-02，直接删除客户订单里的MCC-A0001-01
      // 如果客户订单只有MCC-A0001-01没有MCC-A0001-02，把客户订单里的MCC-A0001-01改为MCC-A0001-02

      // 第二步：删除货号建档里的MCC-A0001-01

      for (const i of this.tableData) {
        if (i.kindsNumber == this.kindsNumber) {
          // alert('sda')
          let obj = {
            kindsNumber: this.kindsNumber,
            newKindsNumber: this.newKindsNumber,
            id: this.id
          }
          this.$confirm(
            '此操作将修改客户订单并删除此货号的数据, 是否继续?',
            '提示',
            {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }
          )
            .then(() => {
              // 修改
              putkindsNumber(obj).then((res) => {
                // console.log(res)
                this.getAllData({
                  kindsNumberStr: this.kindsNumber,
                  mnemonicCode: this.mnemonicCode,
                  commodityType: this.commodityType,
                  brandedName: this.brandedName
                })
                if (res.data.code == 200) {
                  // 删除
                  deleteArtNo({ id: this.id }).then((r) => {
                    // console.log(r)
                    if (r.data.code == 200) {
                      this.dataLen--
                      this.$message({
                        type: 'success',
                        message: '操作成功!'
                      })
                    } else {
                      this.$message({
                        type: 'info',
                        message: '修改成功，删除原货号信息失败'
                      })
                    }
                    this.getAllData({
                      kindsNumberStr: this.kindsNumber,
                      mnemonicCode: this.mnemonicCode,
                      commodityType: this.commodityType,
                      brandedName: this.brandedName
                    })
                  })
                } else {
                  this.$message({
                    type: 'info',
                    message: '修改失败'
                  })
                }
              })
            })
            .catch(() => {
              this.$message({
                type: 'info',
                message: '已取消操作'
              })
            })
        }
      }
    },

    //添加货号
    addNumber() {
      if (this.kindsNumber == '') {
        this.$message({
          type: 'warning',
          message: '请填写货号或款号或选中一条数据添加!'
        })
        return
      }
      let params = { pageSize: 999, page: 1, groupType: 1 }
      if (this.id) {
        params.styleNumber = this.clickStyle
      } else {
        params.styleNumber = this.kindsNumber
      }
      getArtNo(params).then((res) => {
        // console.log(res.data)
        if (res.data.code == 200) {
          for (let n of res.data.data) {
            // this.content.push(n.kindsNumber)
            if (this.content.indexOf(n.kindsNumber) == -1) {
              this.content.push(n.kindsNumber)
            }
          }
          this.kindsNumber = ''
          this.mnemonicCode = ''
          this.commodityType = ''
          this.$message({
            message: '添加成功',
            type: 'success'
          })
        }
      })
    },

    // 获取所有数据
    getAllData(p = {}) {
      // console.log(p, '获取所有数据')
      this.id = ''
      p.page = this.currentPage
      p.pageSize = this.limit
      p.groupType = this.tableType
      this.clickStyle = ''
      this.allData = []
      this.tableData = this.allData
      getArtNo(p).then((res) => {
        // console.log(res)
        this.allData = res.data.data || []
        if (!this.allData.length) {
          this.$message.info('暂无数据')
          return
        }
        this.allData.sort((a, b) => {
          if (a.styleNumber == b.styleNumber) {
            if (a.colorNo == b.colorNo) {
              return a.relevanceSize.localeCompare(b.relevanceSize)
            } else {
              return a.colorNo.localeCompare(b.colorNo)
            }
          } else {
            return a.styleNumber.localeCompare(b.styleNumber)
          }
        })
        let exist = 0
        for (const i of res.data.data) {
          if (!this.waveBandList.length) {
            this.waveBandList.push({ value: i.waveBand, label: i.waveBand })
          } else {
            for (const j of this.waveBandList) {
              if (j.value == i.waveBand) {
                exist = 1
                break
              }
              exist = 0
            }
            if (!exist) {
              this.waveBandList.push({ value: i.waveBand, label: i.waveBand })
            }
          }
        }
        this.tableData = this.allData
        this.dataLen = res.data.total
        this.$forceUpdate()
        this.$nextTick(() => {
          this.$refs.table.doLayout()
        })
      })
    },

    rowClick(e) {
      // console.log(e)
      this.dataLen = 0
      switch (this.tableType) {
        case 1:
          this.kindsNumber = e.kindsNumber
          break
        case 2:
          this.kindsNumber = e.styleNumber
          break
        case 3:
          this.kindsNumber = e.styleNumber
          break
      }
      this.currentPage = 1
      this.tableTypeChange = !this.tableTypeChange
      this.clickStyle = e.styleNumber
      ;(this.id = e.id), (this.mnemonicCode = e.mnemonicCode)
      this.details = e
    },
    newClick() {
      this.show = 'block'
      this.isCreate = true
    },
    closeClick() {
      this.show = 'none'
    },
    // 双击打开编辑
    editClick(e) {
      if (this.kindsNumber == '') {
        this.$alert('请点击选中一条数据编辑', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      getArtNo({
        pageSize: 9999,
        styleNumber: e.styleNumber,
        groupType: 1
      }).then((res) => {
        let list = res.data.data
        this.isCreate = false
        this.details = e
        this.show = 'block'

        let tmpList = [e]
        let colorList = [{ colorNo: e.colorNo, colorName: e.colorName }]
        let sizeList = [e.size]
        let hasColor = 0
        let hasSize = 0
        for (const i of list) {
          if (i.styleNumber == e.styleNumber) {
            tmpList.push(i)
          }
        }

        for (const i of tmpList) {
          for (const c of colorList) {
            if (i.colorNo == c.colorNo) {
              hasColor = 0
              break
            }
            hasColor = 1
          }
          if (hasColor) {
            colorList.push({ colorNo: i.colorNo, colorName: i.colorName })
          }

          for (const s of sizeList) {
            if (i.size == s) {
              hasSize = 0
              break
            }
            hasSize = 1
          }
          if (hasSize) {
            sizeList.push(i.size)
          }
        }

        this.details.colorList = colorList
        this.details.sizeList = sizeList
      })
    },

    // 改正部类
    correctCT() {
      correctCommodityType().then((res) => {
        // console.log(res)
        if (res.data.code == 200) {
          this.$message({
            message: '改正部类成功',
            type: 'success'
          })
          this.getAllData({
            kindsNumberStr: this.kindsNumber,
            mnemonicCode: this.mnemonicCode,
            commodityType: this.commodityType,
            brandedName: this.brandedName
          })
        }
      })
    },
    // 导入
    async handleImportInputClick(evt) {
      const params = {
        kindsNumber: '货号',
        styleNumber: '款号',
        brandedCompany: '品牌公司',
        mnemonicCode: '助记码',
        supplier: '供应商编号',
        brandedName: '品牌名称',
        colorName: '颜色名称',
        commodityName: '品名名称',
        quarter: '季度',
        size: '尺码',
        vipPrice: 'VIP价',
        clothing: '男/女装',
        accessoryName: '附件名称',
        waveBand: '波段',
        sellingPrice: '售价',
        manufacturerPrice: '厂价',
        generalizePrice: '推广价'
      }
      const dataList = await importExcel(evt, params)
      const { data } = await importKindsNumber(dataList)
      if (data && data.code === 200) {
        this.$message.success(data.msg)
        this.switchList = data.data || []
        this.searchArtNo()
      }
    },
    // 批量导入修改
    async handleImportInputUpdateClick(evt) {
      const params = {
        brandedName: '品牌',
        kindsNumber: '货号',
        sellingPrice: '售价'
      }
      const dataList = await importExcel(evt, params)
      const { data } = await importKindsNumberByUpdate(dataList)
      if (data && data.code === 200) {
        this.$message.success(data.msg)
        this.switchList = data.data || []
        this.searchArtNo()
      }
    },
    // readExcel(e) {
    //   const files = e.target.files
    //   if (files.length <= 0) {
    //     //如果没有文件名
    //     return false
    //   } else if (!/\.(xls|xlsx)$/.test(files[0].name.toLowerCase())) {
    //     this.$Message.error('上传格式不正确，请上传xls或者xlsx格式')
    //     return false
    //   }

    //   const fileReader = new FileReader()
    //   fileReader.onload = (ev) => {
    //     try {
    //       const data = ev.target.result
    //       const workbook = XLSX.read(data, {
    //         type: 'binary'
    //       })
    //       const wsname = workbook.SheetNames[0] //取第一张表
    //       const ws = XLSX.utils.sheet_to_json(workbook.Sheets[wsname]) //生成json表格内容
    //       console.log(ws)

    //       if (!ws.length) {
    //         this.$message.error('表格无数据')
    //         this.$refs.upload.value = ''
    //         return
    //       }

    //       if (ws[0].hasOwnProperty('__EMPTY')) {
    //         this.$message.error(
    //           '解析失败,表头需放在第一行,并且禁止空表头下有数据'
    //         )
    //         this.$refs.upload.value = ''
    //         return
    //       }
    //       // return
    //       let wsLength
    //       let sucNum = 0
    //       let faiNum = 0
    //       let faiList = []
    //       let finNum = 0
    //       let that = this

    //       function cutSpace(v) {
    //         if (typeof v == 'number') {
    //           v = v.toString()
    //         }
    //         return v.replace(/(^\s*)|(\s*$)/g, '')
    //       }
    //       if (ws[0].成份1) {
    //         // 导入成分表
    //         wsLength = ws.length

    //         let titleList = [
    //           '含有码',
    //           '款号',
    //           '安全类别',
    //           '执行标准',
    //           '上下装',
    //           '洗涤类型'
    //         ]
    //         for (const i of titleList) {
    //           if (!ws[0].hasOwnProperty(i)) {
    //             this.$message.error('表头 ' + i + ' 有空格或不存在')
    //             this.$refs.upload.value = ''
    //             return
    //           }
    //         }

    //         function createIngredient() {
    //           let i = finNum
    //           try {
    //             for (const key in ws[i]) {
    //               if (Object.hasOwnProperty.call(ws[i], key)) {
    //                 const element = ws[i][key]
    //                 ws[i][key] = cutSpace(element)
    //               }
    //             }

    //             let sellingPrice
    //             getArtNo({ styleNumber: ws[i].款号, pageSize: 1, groupType: 1 })
    //               .then((res) => {
    //                 if (res.data.data.length) {
    //                   sellingPrice = res.data.data[0].sellingPrice
    //                   return getKindsNumberIngredient({
    //                     typeNumber: ws[i].款号
    //                   })
    //                 } else return
    //               })
    //               .then((res) => {
    //                 if (!res) return
    //                 // console.log(res)
    //                 let d = {}
    //                 if (res.data.data.length) {
    //                   // 修改
    //                   // console.log('修改')
    //                   d = res.data.data[0]
    //                   d.safetyType = ws[i].安全类别
    //                   d.standard = ws[i].执行标准
    //                   d.containNo = ws[i].含有码
    //                   d.washingType = ws[i].洗涤类型
    //                   ;(d.upDown = ws[i].上下装 == '上' ? 0 : 1),
    //                     (d.ingredientOne = ws[i].成份1 || '')
    //                   d.ingredientTwo = ws[i].成份2 || ''
    //                   d.ingredientThree = ws[i].成份3 || ''
    //                   d.ingredientFour = ws[i].成份4 || ''
    //                   d.ingredientFive = ws[i].成份5 || ''
    //                   d.ingredientSix = ws[i].成份6 || ''
    //                   d.ingredientSeven = ws[i].成份7 || ''
    //                   d.ingredientEight = ws[i].成份8 || ''
    //                   d.ingredientNine = ws[i].成份9 || ''
    //                   d.ingredientTen = ws[i].成份10 || ''
    //                   d.ingredientEleven = ws[i].成份11 || ''
    //                   d.ingredientTwelve = ws[i].成份12 || ''
    //                   d.ingredientThirteen = ws[i].成份13 || ''
    //                   d.ingredientFourteen = ws[i].成份14 || ''
    //                   d.ingredientFifteen = ws[i].成份15 || ''
    //                   d.ingredientSixteen = ws[i].成份16 || ''
    //                   d.ingredientSeventeen = ws[i].成份17 || ''
    //                   d.ingredientEighteen = ws[i].成份18 || ''
    //                   d.ingredientNineteen = ws[i].成份19 || ''
    //                   d.ingredientTwenty = ws[i].成份20 || ''
    //                   d.ingredientTwentyOne = ws[i].成份21 || ''
    //                   d.ingredientTwentyTwo = ws[i].成份22 || ''
    //                   d.ingredientTwentyThree = ws[i].成份23 || ''
    //                   d.ingredientTwentyFour = ws[i].成份24 || ''
    //                   d.ingredientTwentyFive = ws[i].成份25 || ''
    //                   delete d.time
    //                   // console.log(d)
    //                   return putKindsNumberIngredient(d)
    //                 } else {
    //                   // console.log('新建')
    //                   // 新建
    //                   d = {
    //                     typeNumber: ws[i].款号,
    //                     safetyType: ws[i].安全类别,
    //                     standard: ws[i].执行标准,
    //                     containNo: ws[i].含有码,
    //                     washingType: ws[i].洗涤类型,
    //                     sellingPrice,
    //                     // 0上装1下装
    //                     upDown: ws[i].上下装 == '上' ? 0 : 1,
    //                     ingredientOne: ws[i].成份1 || '',
    //                     ingredientTwo: ws[i].成份2 || '',
    //                     ingredientThree: ws[i].成份3 || '',
    //                     ingredientFour: ws[i].成份4 || '',
    //                     ingredientFive: ws[i].成份5 || '',
    //                     ingredientSix: ws[i].成份6 || '',
    //                     ingredientSeven: ws[i].成份7 || '',
    //                     ingredientEight: ws[i].成份8 || '',
    //                     ingredientNine: ws[i].成份9 || '',
    //                     ingredientTen: ws[i].成份10 || '',
    //                     ingredientEleven: ws[i].成份11 || '',
    //                     ingredientTwelve: ws[i].成份12 || '',
    //                     ingredientThirteen: ws[i].成份13 || '',
    //                     ingredientFourteen: ws[i].成份14 || '',
    //                     ingredientFifteen: ws[i].成份15 || '',
    //                     ingredientSixteen: ws[i].成份16 || '',
    //                     ingredientSeventeen: ws[i].成份17 || '',
    //                     ingredientEighteen: ws[i].成份18 || '',
    //                     ingredientNineteen: ws[i].成份19 || '',
    //                     ingredientTwenty: ws[i].成份20 || '',
    //                     ingredientTwentyOne: ws[i].成份21 || '',
    //                     ingredientTwentyTwo: ws[i].成份22 || '',
    //                     ingredientTwentyThree: ws[i].成份23 || '',
    //                     ingredientTwentyFour: ws[i].成份24 || '',
    //                     ingredientTwentyFive: ws[i].成份25 || ''
    //                   }
    //                   // console.log(d)
    //                   return postKindsNumberIngredient(d)
    //                 }
    //               })
    //               .then((res) => {
    //                 finNum++
    //                 if (finNum != wsLength) {
    //                   createIngredient()
    //                 }
    //                 if (res) {
    //                   if (res.data.code == 200) {
    //                     sucNum++
    //                   } else {
    //                     faiNum++
    //                     faiList.push(ws[i].款号)
    //                   }
    //                   // console.log(sucNum, faiNum)
    //                 } else {
    //                   faiNum++
    //                   faiList.push(ws[i].款号)
    //                   // console.log(sucNum, faiNum)
    //                   return
    //                 }
    //               })
    //           } catch (err) {
    //             console.log(err)
    //             faiNum++
    //             faiList.push(e.款号)
    //             finNum++
    //             if (finNum != wsLength) {
    //               createIngredient()
    //             }
    //           }
    //         }
    //         createIngredient()
    //       } else {
    //         // 货号建档
    //         let titleList = [
    //           '助记码',
    //           '品名',
    //           '品牌',
    //           '售价',
    //           '款号',
    //           '尺码',
    //           '尺码种类',
    //           '尺码编号',
    //           '货号',
    //           '颜色',
    //           '色号',
    //           '季度',
    //           '厂价'
    //         ]
    //         for (const i of titleList) {
    //           if (!ws[0].hasOwnProperty(i)) {
    //             this.$message.error('表头 ' + i + ' 有空格或不存在')
    //             this.$refs.upload.value = ''
    //             return
    //           }
    //         }

    //         ws.sort((a, b) => {
    //           return a.款号.toString().localeCompare(b.款号.toString())
    //         })

    //         let lastType = ''
    //         let createList = []
    //         ws.forEach((e) => {
    //           e.款号 = cutSpace(e.款号)
    //           if (e.款号 != lastType) {
    //             // 去空格
    //             for (const key in e) {
    //               if (Object.hasOwnProperty.call(e, key)) {
    //                 const element = e[key]
    //                 e[key] = cutSpace(element)
    //               }
    //             }

    //             lastType = e.款号
    //             e.colorStr = e.色号 + ':' + e.颜色
    //             e.sizeList = [e.尺码]

    //             createList.push(e)
    //           } else {
    //             e.色号 = cutSpace(e.色号)
    //             e.颜色 = cutSpace(e.颜色)
    //             e.尺码 = cutSpace(e.尺码)

    //             let tmp = createList[createList.length - 1]
    //             if (tmp.colorStr.indexOf(e.色号) == -1) {
    //               tmp.colorStr = tmp.colorStr + ',' + e.色号 + ':' + e.颜色
    //             }
    //             if (tmp.sizeList.indexOf(e.尺码) == -1) {
    //               tmp.sizeList.push(e.尺码)
    //             }
    //           }
    //         })
    //         // console.log(createList)
    //         wsLength = createList.length
    //         // return

    //         function create() {
    //           let e = createList[finNum]

    //           try {
    //             e.quarterID = that.quarterMap[e.季度] || ''
    //             if (!e.quarterID) {
    //               postQuarter({ quarterName: e.季度 }).then((res) => {
    //                 e.quarterID = res.data.data
    //                 that.quarterMap[e.季度] = e.quarterID
    //               })
    //             }

    //             for (const i of that.brandedNameList) {
    //               if (e.品牌 == i.label) {
    //                 e.品牌公司 = i.company
    //                 break
    //               }
    //             }

    //             getArtNo({
    //               pageSize: 9999,
    //               styleNumber: e.款号,
    //               groupType: 1
    //             })
    //               .then((res) => {
    //                 // console.log(res)
    //                 if (res.data.data.length) {
    //                   for (const f of res.data.data) {
    //                     if (e.colorStr.indexOf(f.colorNo) == -1) {
    //                       e.colorStr =
    //                         e.colorStr + ',' + f.colorNo + ':' + f.colorName
    //                     }
    //                     if (e.sizeList.indexOf(f.size) == -1) {
    //                       e.sizeList.push(f.size)
    //                     }
    //                   }
    //                 }
    //                 return getCommodityName({ name: e.品名, limit: 99999 })
    //               })
    //               .then((res) => {
    //                 if (res.data.total != null) {
    //                   e.部类 = res.data.data[0].commodityTypeNo
    //                 } else {
    //                   e.部类 = ''
    //                 }
    //                 return getManufacturer({ limit: 99999 })
    //               })
    //               .then((res) => {
    //                 for (const j of res.data.data) {
    //                   if (j.name == e.品牌公司) {
    //                     e.品牌公司编号 = j.no
    //                     break
    //                   }
    //                 }
    //                 let sizeList = []
    //                 e.sizeList.forEach((f) => {
    //                   sizeList.push(that.sizeMap[e.尺码种类][f])
    //                 })
    //                 let d = {
    //                   kindsNumber: {
    //                     kindSort: 1,
    //                     styleNumber: e.款号,
    //                     commodityName: e.品名,
    //                     colorName: e.colorStr,
    //                     // 品牌公司
    //                     brandedCompany: e.品牌公司,
    //                     // 部类
    //                     commodityType: e.部类,
    //                     sellingPrice: e.售价,
    //                     sellingPriceOne: e.售价,
    //                     brandedName: e.品牌,
    //                     supplier: e.供应商,
    //                     quarter: e.quarterID,
    //                     mnemonicCode: e.助记码,
    //                     manufacturerPrice: e.厂价
    //                   },
    //                   sizeList
    //                 }
    //                 console.log(d)
    //                 return postKindsNumber(JSON.stringify(d))
    //               })
    //               .then((res) => {
    //                 // console.log(res)
    //                 if (res.data.code == 200) {
    //                   sucNum++
    //                 } else {
    //                   faiNum++
    //                   faiList.push(e.款号)
    //                 }
    //                 // console.log(sucNum, faiNum)
    //                 finNum++
    //                 if (finNum != wsLength) {
    //                   create()
    //                 }
    //               })
    //           } catch (err) {
    //             // console.log(err)
    //             faiNum++
    //             faiList.push(e.款号)
    //             finNum++
    //             if (finNum != wsLength) {
    //               create()
    //             }
    //           }
    //         }
    //         create()
    //       }
    //       // return
    //       let int = setInterval(() => {
    //         if (finNum == wsLength) {
    //           clearInterval(int)
    //           this.getAllData()
    //           this.$alert(
    //             `导入完成，失败${faiNum}条。${
    //               faiNum ? `失败款号为${String(faiList)}` : ''
    //             }`,
    //             '',
    //             {
    //               confirmButtonText: '确定'
    //             }
    //           )
    //           if (faiNum) {
    //             let str = faiList.join('\n')
    //             this.exportRaw(str, '失败款号.txt')
    //           }
    //         }
    //       })
    //     } catch (e) {
    //       console.log(e)
    //       return false
    //     }
    //   }
    //   fileReader.readAsBinaryString(files[0])
    // },

    // 导出
    async handleCommand(command) {
      // const title = {
      //   0:'货号',
      //   1:'款号色号',
      //   2:'款号',
      //   3:'货号',
      // }
      // const requestData = {
      //   exportGroupType: command, // 分组条件 0.货号 1.款色号 2.款号 3.代销商
      //   brandedCompany: this.brandedName, // 品牌公司名称
      //   commodityTypeNo: this.commodityType, // 部类编号
      //   kindsNumberValue: this.kindsNumber, // 货号值
      //   mnemonicCode: this.mnemonicCode // 助记码
      // }
      // const res = await getExportLink(requestData)
      // if (res.data) {
      //   exportExcel_2(res.data, '/kinds-number/getExportLink', '货号.xlsx')
      // }
      // return
      // const columns = this.tableConfig.column;
      // let headers = columns.map((item) => {
      //   const obj = {};
      //   if (item.type !== "index") {
      //     obj.key = item.prop;
      //     obj.title = item.label;
      //   }
      //   return obj;
      // });
      // // 清空 空对象
      // headers = headers.filter((value) => Object.keys(value).length !== 0);
      // const name = "职员建档.xlsx";
      // exportExcel(headers, this.tableConfig.tableData, name);

      // 分组条件 0.货号 1.款色号 2.款号 3.代销商
      let noExportList = '尺寸编号,尺寸种类,季度id,'
      // '货号','供应商','助记码','色号','颜色','厂价','售价','正价','售价2','售价3','售价4','VIP价','品名','品牌','季度','尺码','条码','波段','搭配款','原厂商货号','图像','附件','部类','售价','款号','区分条件'
      // '款号','色号','颜色','供应商','助记码','季度','厂价','售价','正价','售价2','售价3','售价4','VIP价','品名','品牌','部类'
      // '款号','供应商','助记码','厂价','售价','正价','售价2','售价3','售价4','VIP价','品名','品牌','季度','波段','搭配款','原厂商货号','图像'
      // 款号,色号,颜色,尺寸编号,尺寸,售价,品名名称,品牌名称,货号,助记码,尺寸种类
      switch (command) {
        case '0':
          noExportList += ''
          break
        case '1':
          noExportList += '货号,尺码,区分条件,条码,波段,搭配款,原厂商货号,附件'
          break
        case '2':
          noExportList += '货号,色号,颜色,区分条件,尺码,条码,部类,附件'
          break
        case '3':
          noExportList =
            noExportList.slice(10) +
            '供应商,厂价,正价,售价2,售价3,售价4,VIP价,季度,条码,波段,搭配款,原厂商货号,图像,附件,部类,区分条件'
          break
        default:
          break
      }
      // console.log(noExportList)
      getExportLink({
        exportGroupType: command,
        brandedCompany: this.brandedName,
        commodityTypeNo: this.commodityType,
        kindsNumberValue: this.kindsNumber,
        mnemonicCode: this.mnemonicCode,
        noExportList
      }).then((res) => {
        if (res.data.code == 200 && res.data.data) {
          location.href = res.data.data
        }
      })
      return
      let column
      getArtNo({
        page: this.currentPage,
        pageSize: this.limit,
        groupType: command == 4 ? 1 : command
      }).then((res) => {
        let list = res.data.data || []
        list.forEach((e) => {
          e.kindsNumber += '&nbsp;'
          e.styleNumber += '&nbsp;'
          e.colorNo += '&nbsp;'
          for (const key in e) {
            if (Object.hasOwnProperty.call(e, key)) {
              const element = e[key]
              if (element == null) {
                e[key] = ''
              }
            }
          }
        })
        switch (command) {
          case '1':
            // 货号
            column = [
              { key: 'kindsNumber', title: '货号', type: 'text' },
              { key: 'supplier', title: '供应商', type: 'text' },
              { key: 'mnemonicCode', title: '助记码', type: 'text' },
              { key: 'colorNo', title: '色号', type: 'text' },
              { key: 'colorName', title: '颜色', type: 'text' },
              { key: 'manufacturerPrice', title: '厂价', type: 'text' },
              { key: 'sellingPrice', title: '售价', type: 'text' },
              { key: 'sellingPriceOne', title: '正价', type: 'text' },
              { key: 'sellingPriceTwo', title: '售价2', type: 'text' },
              { key: 'sellingPriceThree', title: '售价3', type: 'text' },
              { key: 'sellingPriceFour', title: '售价4', type: 'text' },
              { key: 'vipPrice', title: 'VIP价', type: 'text' },
              { key: 'typeName', title: '部类名称', type: 'text' },
              { key: 'commodityName', title: '品名', type: 'text' },
              { key: 'brandedName', title: '品牌', type: 'text' },
              { key: 'quarterName', title: '季度', type: 'text' },
              { key: 'size', title: '尺码', type: 'text' },
              { key: 'kindsNumber', title: '条码', type: 'text' },
              { key: 'waveBand', title: '波段', type: 'text' },
              { key: 'matchStyle', title: '搭配款', type: 'text' },
              {
                key: 'originalManufacturerKindsNumber',
                title: '原厂商货号',
                type: 'text'
              },
              { key: 'image', title: '图像', type: 'text' },
              { key: 'accessoryName', title: '附件', type: 'text' },
              { key: 'commodityType', title: '部类', type: 'text' },
              { key: 'styleNumber', title: '款号', type: 'text' },
              { key: 'differentiateCondition', title: '区分条件', type: 'text' }
            ]
            table2excel(column, list, '货号表.xls')
            break
          case '3':
            // 款号色号
            column = [
              { key: 'styleNumber', title: '款号', type: 'text' },
              { key: 'supplier', title: '供应商', type: 'text' },
              { key: 'mnemonicCode', title: '助记码', type: 'text' },
              { key: 'colorNo', title: '色号', type: 'text' },
              { key: 'colorName', title: '颜色', type: 'text' },
              { key: 'manufacturerPrice', title: '厂价', type: 'text' },
              { key: 'sellingPrice', title: '售价', type: 'text' },
              { key: 'sellingPriceOne', title: '正价', type: 'text' },
              { key: 'sellingPriceTwo', title: '售价2', type: 'text' },
              { key: 'sellingPriceThree', title: '售价3', type: 'text' },
              { key: 'sellingPriceFour', title: '售价4', type: 'text' },
              { key: 'vipPrice', title: 'VIP价', type: 'text' },
              { key: 'typeName', title: '部类名称', type: 'text' },
              { key: 'commodityName', title: '品名', type: 'text' },
              { key: 'brandedName', title: '品牌', type: 'text' },
              { key: 'quarterName', title: '季度', type: 'text' },
              { key: 'waveBand', title: '波段', type: 'text' },
              { key: 'matchStyle', title: '搭配款', type: 'text' },
              {
                key: 'originalManufacturerKindsNumber',
                title: '原厂商货号',
                type: 'text'
              },
              { key: 'image', title: '图像', type: 'text' }
            ]
            table2excel(column, list, '款号色号表.xls')
            break
          case '2':
            // 款号
            column = [
              { key: 'styleNumber', title: '款号', type: 'text' },
              { key: 'supplier', title: '供应商', type: 'text' },
              { key: 'mnemonicCode', title: '助记码', type: 'text' },
              { key: 'quarterName', title: '季度', type: 'text' },
              { key: 'manufacturerPrice', title: '厂价', type: 'text' },
              { key: 'sellingPrice', title: '售价', type: 'text' },
              { key: 'sellingPriceOne', title: '正价', type: 'text' },
              { key: 'sellingPriceTwo', title: '售价2', type: 'text' },
              { key: 'sellingPriceThree', title: '售价3', type: 'text' },
              { key: 'sellingPriceFour', title: '售价4', type: 'text' },
              { key: 'vipPrice', title: 'VIP价', type: 'text' },
              { key: 'typeName', title: '部类名称', type: 'text' },
              { key: 'commodityName', title: '品名', type: 'text' },
              { key: 'brandedName', title: '品牌', type: 'text' },
              { key: 'commodityType', title: '部类', type: 'text' }
            ]
            table2excel(column, list, '款号表.xls')
            break
          case '4':
            // 代销商
            column = [
              { key: 'styleNumber', title: '款号', type: 'text' },
              { key: 'colorNo', title: '色号', type: 'text' },
              { key: 'colorName', title: '颜色', type: 'text' },
              { key: 'sizeNo', title: '尺码编号', type: 'text' },
              { key: 'size', title: '尺码', type: 'text' },
              { key: 'manufacturerPrice', title: '厂价', type: 'text' },
              { key: 'sellingPrice', title: '售价', type: 'text' },
              { key: 'typeName', title: '部类名称', type: 'text' },
              { key: 'commodityName', title: '品名', type: 'text' },
              { key: 'brandedName', title: '品牌', type: 'text' },
              { key: 'kindsNumber', title: '货号', type: 'text' },
              { key: 'mnemonicCode', title: '助记码', type: 'text' },
              { key: 'sizeKind', title: '尺码种类', type: 'text' }
            ]
            table2excel(column, list, '代销商表.xls')
            break
        }
      })
    },

    // 每页显示页数改变
    handleSizeChange(val) {
      this.limit = val
      this.currentPage = 1
      this.tableTypeChange = !this.tableTypeChange
      this.getAllData({
        kindsNumberStr: this.kindsNumber,
        mnemonicCode: this.mnemonicCode,
        commodityType: this.commodityType,
        brandedName: this.brandedName
      })
      return
      switch (this.tableType) {
        case 1:
          this.dataLen = this.allData.length
          this.tableData = this.allData.slice(
            (this.currentPage - 1) * this.limit,
            this.currentPage * this.limit
          )
          break
        case 2:
          this.dataLen = this.styleNumberColorList.length
          this.tableData = this.styleNumberColorList.slice(
            (this.currentPage - 1) * this.limit,
            this.currentPage * this.limit
          )
          break
        case 3:
          this.dataLen = this.styleNumberList.length
          this.tableData = this.styleNumberList.slice(
            (this.currentPage - 1) * this.limit,
            this.currentPage * this.limit
          )
          break
      }
    },
    // 当前页改变
    handleCurrentChange(val) {
      this.currentPage = val
      this.getAllData({
        kindsNumberStr: this.kindsNumber,
        mnemonicCode: this.mnemonicCode,
        commodityType: this.commodityType,
        brandedName: this.brandedName
      })
      return
      switch (this.tableType) {
        case 1:
          this.tableData = this.allData.slice(
            (this.currentPage - 1) * this.limit,
            this.currentPage * this.limit
          )
          break
        case 2:
          this.tableData = this.styleNumberColorList.slice(
            (this.currentPage - 1) * this.limit,
            this.currentPage * this.limit
          )
          break
        case 3:
          this.tableData = this.styleNumberList.slice(
            (this.currentPage - 1) * this.limit,
            this.currentPage * this.limit
          )
          break
      }
    },
    typeChange(a) {
      this.currentPage = 1
      this.tableTypeChange = !this.tableTypeChange
      // return
      // if (!this.allData.length) {
      //   this.tableData = []
      //   this.dataLen = 0
      //   return
      // }
      if (a == 1) {
        // this.tableData = this.allData.slice(0,this.limit)
        this.tableHeader = [
          '货号',
          '供应商',
          '助记码',
          '色号',
          '颜色',
          '厂价',
          '售价',
          '正价',
          '售价2',
          '售价3',
          '售价4',
          'VIP价',
          '品名',
          '品牌',
          '季度',
          '尺码',
          '条码',
          '波段',
          '搭配款',
          '原厂商货号',
          '图像',
          '附件',
          '部类',
          '售价',
          '款号',
          '区分条件'
        ]
        // this.dataLen = this.allData.length
      } else if (a == 2) {
        // this.tableData = this.styleNumberColorList.slice(0,this.limit)
        this.tableHeader = [
          '款号',
          '供应商',
          '助记码',
          '厂价',
          '售价',
          '正价',
          '售价2',
          '售价3',
          '售价4',
          'VIP价',
          '品名',
          '品牌',
          '季度',
          '波段',
          '搭配款',
          '原厂商货号',
          '图像'
        ]
        // this.dataLen = this.styleNumberColorList.length
      } else if (a == 3) {
        // this.tableData = this.styleNumberList.slice(0,this.limit)
        this.tableHeader = [
          '款号',
          '色号',
          '颜色',
          '供应商',
          '助记码',
          '季度',
          '厂价',
          '售价',
          '正价',
          '售价2',
          '售价3',
          '售价4',
          'VIP价',
          '品名',
          '品牌',
          '部类'
        ]
        // this.dataLen = this.styleNumberList.length
      }
      this.getAllData({
        kindsNumberStr: this.kindsNumber,
        mnemonicCode: this.mnemonicCode,
        commodityType: this.commodityType,
        brandedName: this.brandedName
      })
    },

    // 新建货号成功
    addArtNoSuc(k) {
      this.getAllData({ styleNumber: k })
    },

    edit() {
      // 双击成分表或输入了已有款号从新建变成编辑
      this.isCreate = false
    },

    check(row) {
      // console.log(row)
      if (row.image) {
        this.imgSrc = row.image
        this.showImg = true
      } else {
        this.$message('暂无图片')
      }
    }
  },
  watch: {
    dataLen(a, b) {
      // console.log(a)
      this.pagesNum = Math.ceil(this.dataLen / this.limit)
    },
    limit(a, b) {
      this.pagesNum = Math.ceil(this.dataLen / this.limit)
    },
    mnemonicCode(a, b) {
      if (a) {
        this.mnemonicCode = a.toUpperCase().trim()
      }
    },
    kindsNumber(a, b) {
      this.kindsNumber = a.toUpperCase().trim()
    },
    newKindsNumber(a, b) {
      this.newKindsNumber = a.toUpperCase().trim()
    }
  }
}
</script>
